<?php
/**
 * @package       nuo
 * @subpackage    nuo.user
 * @author        Nam Nguyen <nam.ngvan@gmail.com>
 * @version       1.0
 * @since         Apr 18, 2013
 */
class Nuo_User_Guest implements Nuo_User_Interface
{

	/**
	 * Keep Authorization object
	 * @access  protected
	 * @var     Nuo_Acl_Interface
	 */
	protected $_acl = NULL;

	/**
	 * Get display name
	 * @access   public
	 * @return   string
	 */
	function getTitle()
	{
		return Intl::__('guest');
	}

	/**
	 * Get viewer user id
	 * @access    public
	 * @return   int
	 */
	function getId()
	{
		return 0;
	}

	/**
	 * @access   public
	 * @return   bool
	 */
	function isMember()
	{
		return false;
	}

	/**
	 * Is Guest ?
	 * @access   public
	 * @return   bool
	 */
	function isGuest()
	{
		return true;
	}

	/**
	 * @access   public
	 * @param    Object  $object
	 * @return   bool
	 */
	function isOwner($object)
	{
		return FALSE;
	}

	/**
	 * Set new permission value associate with action
	 * WARNING:
	 * + Do not store this value to database
	 * + To store new value, use permission api instead
	 * @access  public
	 * @param   string  $action
	 * @param   mixed   $value
	 * @return  Nuo_Permission
	 */
	function setAllow($action, $value)
	{
		return $this -> getAcl() -> setAllow($action, $value);
	}

	/**
	 * Get permission of this action
	 * @access public  int
	 * @param  string  $action
	 * @return mixed
	 */
	function allow($action)
	{
		return $this -> getAcl() -> allow($action);
	}

	/**
	 * Required user to allow to action.
	 * + If user has authorized to do "action", return true
	 * + If user has no permission to pass "action", redirect user to login required
	 * or permission deined page.
	 * + If you want to get permission instead of required user, please use
	 * ":allow()" instead of this method.
	 * @access  public
	 * @param   string   $action
	 * @param   int      $def
	 * @return  void
	 */
	function required($action)
	{
		return $this -> getAcl() -> required($action);
	}

	/**
	 * Get Acl permission for current user
	 * @access  public
	 * @return  Nuo_Acl_User
	 */
	function getAcl()
	{
		if (NULL == $this -> _acl)
		{
			$this -> _acl = Nuo_Acl_User::factory(0);
		}
		return $this -> _acl;
	}

	/**
	 * @access public
	 * @return string
	 */
	function __toString()
	{
		return $this->getTitle();
	}
	
	function getPhotoUrl(){
		return '';
	}
	
	function getUrl(){
		return '';
	}
}
